﻿using Sustainalytics.ClientDW.DataAccessLayer;
using Sustainalytics.DataLayer;
using Sustainalytics.DataLayer.Shared;
using Sustainalytics.Entities.Governance;
using Sustainalytics.Governance.BusinessLogic.Model;
using System;
using Xunit;

namespace Sustainalytics.Governance.BusinessLogic.Tests
{
    public class GovernanceManagerTest
    {
        private Guid _companyId;

        private string _baseUrl;
        private string _clientDwConnectionString;
        private string _fileConnectionString;
        private string _governanceConnectionString;

        [Fact]
        public void Initialize()
        {
            _companyId = Guid.Parse("26794010-9d68-42c7-b8a1-bcb5c3b508a9");
            _baseUrl = "http://localhost:10280";
            _clientDwConnectionString = "mongodb://localhost:27017/ClientDW_A";
            _fileConnectionString = "mongodb://localhost:27017/GovernanceInputFile";
            _governanceConnectionString = "mongodb://localhost:27017/GovernanceDW_A";
        }
    
        /// <summary>
        /// A <see cref="GovernanceManager.GetProfileByCompany(System.Guid)"/>
        /// </summary>
        [Fact]
        public void GetProfileByCompanyMustReturnCompany()
        {
            Initialize();

            var _governanceInputFileRepository = new RepositoryCollection<GovernanceInsightInputFile>(_fileConnectionString);
            var _governanceInputFileRepositoryWithFiles = new RepositoryCollectionWithFile<GovernanceInsightInputFile>(_fileConnectionString);
            var _governancePdfProfileMetadataRepository = new RepositoryCollection<GovernancePdfProfileMetadata>(_fileConnectionString);

            IClientDwRepository _clientDwRepository = ClientDwRepository.GetInstance(_clientDwConnectionString);
            IGovernanceRepository _governanceRepository = new GovernanceRepository(_governanceConnectionString);

            GovernanceManager _target = new GovernanceManager(_clientDwRepository, 
                _governanceRepository,
                _governanceInputFileRepository, 
                _governanceInputFileRepositoryWithFiles, 
                _governancePdfProfileMetadataRepository, 
                _baseUrl);

            GovernanceProfileDto returned = _target.GetProfileByCompany(_companyId);
            Assert.NotNull(returned);
        }
    }
}
